



clear all
cd "${data}"	
use "CHES_original.dta", clear

keep lrgen year party_id country 

keep if country == 1 | country == 13 | country == 2 | country == 14 | country == 6 | country == 3 | country == 4 | country == 7 | country == 8 | country == 10 | country == 12 | country == 5 | country == 16 | country == 11 


/*
1. be Belgium
13. aus Austria
2. dk Denmark
14. fin Finland
6. fr France
3. ge Germany
4. gr Greece
7. irl Ireland
8. it Italy
10. nl Netherlands
12. por Portugal
5. esp Spain
16. sv Sweden
11. uk United Kingdom
*/

reshape wide lrgen,i(party_id) j(year)

gen diff_1419 = abs(lrgen2014 - lrgen2019) if lrgen2014!=. & lrgen2019!=.
gen diff_1014 = abs(lrgen2010 - lrgen2014) if lrgen2010!=. & lrgen2014!=.
gen diff_0610 = abs(lrgen2006 - lrgen2010) if lrgen2006!=. & lrgen2010!=.
gen diff_0206 = abs(lrgen2002 - lrgen2006) if lrgen2002!=. & lrgen2006!=.
gen diff_9902 = abs(lrgen1999 - lrgen2002) if lrgen1999!=. & lrgen2002!=.

gen diff_1019 = abs(lrgen2010 - lrgen2019) if lrgen2010!=. & lrgen2019!=.
gen diff_0619 = abs(lrgen2006 - lrgen2019) if lrgen2006!=. & lrgen2019!=.
gen diff_0219 = abs(lrgen2002 - lrgen2019) if lrgen2002!=. & lrgen2019!=.
gen diff_9919 = abs(lrgen1999 - lrgen2019) if lrgen1999!=. & lrgen2019!=.


hist diff_9902, percent color(gs5%50) title("1999-2002") xtitle("") ytitle("") xline(1, lpattern(dash) lcolor(gs5))
graph save "${figures}/h1.gph", replace

hist diff_0206, percent color(gs5%50) title("2002-2006") xtitle("") ytitle("") xline(1, lpattern(dash) lcolor(gs5))
graph save "${figures}/h2.gph", replace

hist diff_0610, percent color(gs5%50) title("2006-2010") xtitle("") ytitle("") xline(1, lpattern(dash) lcolor(gs5))
graph save "${figures}/h3.gph", replace

hist diff_1014, percent color(gs5%50) title("2010-2014") xtitle("") ytitle("") xline(1, lpattern(dash) lcolor(gs5))
graph save "${figures}/h4.gph", replace

hist diff_1419, percent color(gs5%50) title("2014-2019") xtitle("") ytitle("") xline(1, lpattern(dash) lcolor(gs5))
graph save "${figures}/h5.gph", replace

hist diff_9919, percent color(gs5%50) title("1999-2019") xtitle("") ytitle("") xline(1, lpattern(dash) lcolor(gs5))
graph save "${figures}/h6.gph", replace


cd "${figures}"
graph combine h1.gph h2.gph h3.gph h4.gph h5.gph h6.gph , ycommon xcommon
graph save "${figures}/stabilityches.gph", replace
graph export "${figures}/stabilityches.png", replace


